package com.springboot.service.impl;

import com.springboot.mapper.DoctorAppointSetMapper;
import com.springboot.mapper.OrderFormMapper;
import com.springboot.model.DoctorAppointSet;
import com.springboot.model.DoctorAppointSetKey;
import com.springboot.model.OrderForm;
import com.springboot.service.OrderDoctorService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class OrderDoctorServiceImpl implements OrderDoctorService {

    @Autowired
    OrderFormMapper orderFormMapper;

    @Autowired
    DoctorAppointSetMapper doctorAppointSetMapper;

    @Override
    public int checkOrderForm(OrderForm orderForm) {
        try{
            OrderForm i = orderFormMapper.selectByForeignKey(orderForm);
            if(i!=null)
            {
                return 1;
            }
            else {
                return 0;
            }
        }
        catch (Exception e)
        {
            return 0;
        }
    }


    @Override
    public int insertOrderForm(OrderForm orderForm) {
        int i = orderFormMapper.insertSelective(orderForm);
        System.out.println("插入"+i+"行数据");
        return i;
    }

    @Override
    public OrderForm findOrderForm(OrderForm orderForm) {
        return orderFormMapper.selectByForeignKey(orderForm);
    }

    @Override
    public DoctorAppointSet findDoctorAppointSet(DoctorAppointSetKey doctorAppointSetKey) {
        DoctorAppointSet doctorAppointSet = doctorAppointSetMapper.selectByPrimaryKey(doctorAppointSetKey);
        return doctorAppointSet;
    }

    @Override
    public int updataDoctorAppointSet(DoctorAppointSet doctorAppointSet) {
        try {
            int i = doctorAppointSetMapper.updateByPrimaryKey(doctorAppointSet);
            return i;
        }
        catch (Exception e)
        {
            return 0;
        }
    }


}
